<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/layui.css">
</head>
<body>
<input type="hidden" id="examId" value="${examId}">
<form class="layui-form" action="" style="margin: 20px">
    <div class="layui-form-item">
        <label class="layui-form-label">课程</label>
        <div class="layui-input-block">
            <select name="classId" lay-verify="required">
                <c:forEach items="${courseList}" var="couse">
                    <option value="${couse.classId}">${couse.className}</option>
                </c:forEach>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="examSubmit">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
<script src="/static/js/common.js"></script>
<script src="${pageContext.request.contextPath}/static/layui.all.js"></script>
<script>
    var form = layui.form;
    //监听提交
    form.on('submit(examSubmit)', function(data){

        var examId = $("#examId").val();
        var postData = {
            classId: data.field.classId
        }

        console.log(JSON.stringify(data))
        $.operate.post("/admin/online/sendExam?examId=" + examId, postData, function (res) {
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭
            var url = window.location.href;
            window.location.href = url;
            layer.msg("发布成功");

        })
        return false;
    });


</script>
</body>
</html>
